import 'package:flutter/material.dart';

import '../component/UserMessageComponent.dart';

class GenerateUtil {
  static Widget generateAvatar(final String avatarUrl, final double width, final double height) {
    return Container(
      width: width,
      height: height,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(8.0), // 设置圆角的大小
        image: DecorationImage(
          image: NetworkImage(avatarUrl),
          fit: BoxFit.cover, // 控制图片如何填充容器
        ),
      ),
    );
  }

  static Widget generateChatDisplayBox(String message, String avatarUrl, bool isSelf) {
    return Container(
      child: Column(
        children: [
          UserMessageComponent(
            message: message,
            avatarUrl: avatarUrl,
            isSelf: isSelf,
          )
        ],
      ),
    );
  }

  static void showTimedSnackBar(BuildContext context, String message) {
    final scaffoldMessenger = ScaffoldMessenger.of(context);

    scaffoldMessenger.showSnackBar(
      SnackBar(
        content: Text(message),
        duration: Duration(seconds: 3),
      ),
    );
  }
}